package com.iraeta.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.iraeta.common.Result;
import com.iraeta.service.FangKeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController(value = "FangKeController")
@RequestMapping("fangke")
public class FangKeController extends BaseController{
    @Autowired
    FangKeService fangKeService;

    @RequestMapping("getfangkerecord")
    public String getFangKeRecord(@RequestBody JSONObject paramJb){
        String orderId = paramJb.getString("id");
        return fangKeService.getFangKeRecord(orderId);
    }

    @RequestMapping("shenhefangkerecord")
    public String shenHeFangKeRecord(@RequestBody JSONObject paramJb){
        String orderId = paramJb.getString("id");
        int status = paramJb.getIntValue("statusId");
        try {
            fangKeService.shenHeFangKeRecord(orderId, status);
            return this.success();
        }catch (Exception e){
            return JSON.toJSONString(Result.error(e.getMessage()));
        }
    }
}
